<div class="row-content layer-cf">
    <div class="row">
        <div class="layer-u-sm-12 layer-u-md-12 layer-u-lg-12">
            <div class="widget layer-cf">
                <div class="widget-head layer-cf">
                    <div class="widget-title layer-cf">优惠券列表</div>
                </div>
                <div class="widget-body layer-fr">
                    <div class="tips layer-margin-bottom-sm layer-u-sm-12">
                        <div class="pre">
                            <p> 注：优惠券只能抵扣商品金额，最多优惠到0.01元，不能抵扣运费</p>
                        </div>
                    </div>
                    <div class="layer-u-sm-12 layer-u-md-6 layer-u-lg-6">
                        <div class="layer-form-group">
                            <div class="layer-btn-toolbar">
                                <div class="layer-btn-group layer-btn-group-xs">
                                    <a class="layer-btn layer-btn-default layer-btn-success layer-radius"
                                       href="{:url('market.coupon/add')}">
                                        <span class="layer-icon-plus"></span> 新增
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layer-u-sm-12">
                        <table width="100%" class="layer-table layer-table-compact layer-table-striped tpl-table-black">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>名称</th>
                                <th>类型</th>
                                <th>最低消费</th>
                                <th>优惠方式</th>
                                <th>有效期</th>
                                <th>发放总量</th>
                                <th>已领取</th>
                                <th>排序</th>
                                <th>添加时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {if !$list->isEmpty()}
                                {foreach $list as $item}
                                    <tr>
                                        <td class="layer-text-middle">{$item['coupon_id']}</td>
                                        <td class="layer-text-middle">{$item['name']}</td>
                                        <td class="layer-text-middle">{$item['coupon_type']['text']}</td>
                                        <td class="layer-text-middle">{$item['min_price']}</td>
                                        <td class="layer-text-middle">
                                            {if $item['coupon_type']['value'] === 10}
                                                <span>立减 <strong>{$item['reduce_price']}</strong> 元</span>
                                            {elseif $item['coupon_type']['value'] === 20/}
                                                <span>打 <strong>{$item['discount']}</strong> 折</span>
                                            {/if}
                                        </td>
                                        <td class="layer-text-middle">
                                           {if $item['expire_type'] === 10}
                                                <span>领取 <strong>{$item['expire_day']}</strong> 天内有效</span>
                                            {elseif $item['expire_type'] === 20/}
                                                <span>{$item['start_time']['text']}
                                                    ~{$item['end_time']['text']}</span>
                                            {/if}
                                        </td>
                                        <td class="layer-text-middle">{$item['total_num'] === -1 ? '不限制' : $item['total_num']}</td>
                                        <td class="layer-text-middle">{$item['receive_num']}</td>
                                        <td class="layer-text-middle">{$item['sort']}</td>

                                        <td class="layer-text-middle">{$item['create_time']}</td>
                                        <td class="layer-text-middle">
                                            <div class="tpl-table-black-operation">
                                                <a href="{:url('market.coupon/edit', ['coupon_id' => $item['coupon_id']])}">
                                                    <i class="layer-icon-pencil"></i> 编辑
                                                </a>
                                                <a href="javascript:void(0);"
                                                   class="item-delete tpl-table-black-operation-del"
                                                   data-id="{$item['coupon_id']}">
                                                    <i class="layer-icon-trash"></i> 删除
                                                </a>
                                            </div>
                                        </td>
                                    </tr>
                                {/foreach}
                            {else/}
                                <tr>
                                    <td colspan="11" class="layer-text-center">暂无记录</td>
                                </tr>
                           {/if}
                            </tbody>
                        </table>
                    </div>
                    <div class="layer-u-lg-12 layer-cf">
                        <div class="layer-fr">{$list->render()} </div>
                        <div class="layer-fr pagination-total layer-margin-right">
                            <div class="layer-vertical-align-middle">总记录：{$list->total()}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {

        // 删除元素
        var url = "{:url('market.coupon/delete')}";
        $('.item-delete').delete('coupon_id', url);

    });
</script>

